<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of home
 *
 * @author b
 */
class home extends CI_Controller {
    public function view($page = 'home')
    {
        if(!file_exists(APPPATH.'/views/pages/'.$page.'.php'))
        {
            show_404();
        }
        
        $data['title'] = ucfirst($page);
        $this->load->view('templates/header',$data);
        $this->load->view('pages/'.$page,$data);
        $this->load->view('templates/footer',$data);
        //echo 'Hello World';
    }
    
        function __construct()
     {
       parent::__construct();
     }

     function index()
     {
       if($this->session->userdata('logged_in'))
       {
         $session_data = $this->session->userdata('logged_in');
         $data['username'] = $session_data['username'];
         $this->load->view('home_view', $data);
       }
       else
       {
         //If no session, redirect to login page
         redirect('login', 'refresh');
       }
     }

     function logout()
     {
       $this->session->unset_userdata('logged_in');
       session_destroy();
       redirect('home', 'refresh');
     }
    //put your code here
}

?>
